package com.tangmu.rabbits.widget.recycle.divider;

import android.content.Context;
import android.support.v4.content.ContextCompat;

import com.tangmu.rabbits.R;

/**
 * 首页热门GirdView分割线
 * Created by hll On 2017/12/19.
 */
public class GridDividerItemDecoration2 extends Y_DividerItemDecoration {

    private Context context;

    public GridDividerItemDecoration2(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public Y_Divider getDivider(int itemPosition) {
        Y_Divider divider = null;
        switch (itemPosition % 2) {
            case 0:
                //每一行第一个显示rignt和bottom
                divider = new Y_DividerBuilder()
                        .setRightSideLine(true, ContextCompat.getColor(context, R.color.line_e_color), 1f, 0, 0)
                        .setTopSideLine(true, ContextCompat.getColor(context, R.color.line_e_color), 1, 0, 0)
                        .create();
                break;
            case 1:
                //第二个显示Left和bottom
                divider = new Y_DividerBuilder()
                        .setLeftSideLine(true, ContextCompat.getColor(context, R.color.line_e_color), 1f, 0, 0)
                        .setTopSideLine(true, ContextCompat.getColor(context, R.color.line_e_color), 1, 0, 0)
                        .create();
                break;
            default:
                break;
        }
        return divider;
    }
}
